<?php
require_once "checklogin.php";
require_once "../lib/MySQLDB.class.php";
$db=MySQLDB::getInstance();
if(!empty($_POST)){
    $data=$_POST;
    $sql="insert into category (cName,pid) values (?,?)";
    $res=$db->query($sql,"ss",$data);
    if($res){
        layerAlert("类别添加成功！",1,"catelist.php");
    }else{
        layerAlert("类别添加失败！",5,"catelist.php");
    }
}else{
    $sql="select * from category order by id asc";
    $rows=$db->fetchAll($sql);
    $cateArr=getSubTree($rows,0,0);
    require_once "view/cateAdd.html";
}
